/*******************************************
 * Copyright 2007 Aphrodite Framework for javaME .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v2.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * Email : owner@aphroditeme.dev.java.net
 * Contributors:
 *     Kent Elton - initial API and implementation
 *******************************************/

package com.aphrodite.util.log;

/**
 * A Global logger is only initialise once but can be used throughout the
 * application
 * 
 * @author kentelt
 * 
 */
class GlobalLoggerImpl implements GlobalLogger {

	static Appender appender;

	public void error(Object cls, String message) {
		StringBuffer buf = new StringBuffer('[' + LoggerImpl.getDateTime()).append(']').append(" ")
				.append(Logger.ERROR).append(" ").append('[').append(cls.getClass().getName()).append(']').append(" ");
		buf.append(message);
		appender.error(buf);

	}

	public void error(Object cls, String message, Throwable e) {
		StringBuffer buf = new StringBuffer('[' + LoggerImpl.getDateTime()).append(']').append(" ")
				.append(Logger.ERROR).append(" ").append('[').append(cls.getClass().getName()).append(']').append(" ");
		buf.append(message).append("  " + e.toString());
		appender.error(buf);

	}

	public void info(Object cls, String message) {
		StringBuffer buf = new StringBuffer('[' + LoggerImpl.getDateTime()).append(']').append(" ").append(Logger.INFO)
				.append(" ").append('[').append(cls.getClass().getName()).append(']').append(" ");
		buf.append(message);
		appender.error(buf);
	}

	public void warn(Object cls, String message) {
		StringBuffer buf = new StringBuffer('[' + LoggerImpl.getDateTime()).append(']').append(" ").append(Logger.WARN)
				.append(" ").append('[').append(cls.getClass().getName()).append(']').append(" ");
		buf.append(message);
		appender.error(buf);

	}

}
